package com.runtu.domain.activity.service.discount.impl;

import com.runtu.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import com.runtu.domain.activity.service.discount.AbstractDiscountCalculateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @ClassName ZKCalculateService
 * @Description 折扣优惠
 * @date 2025/7/19 20:43
 * @Version 1.0
 */

@Slf4j
@Service("ZK")
public class ZKCalculateService extends AbstractDiscountCalculateService {
    @Override
    protected BigDecimal doCalculate(BigDecimal originalPrice, GroupBuyActivityDiscountVO.GroupBuyDiscount groupBuyDiscount) {


        BigDecimal zk = new BigDecimal(groupBuyDiscount.getMarketExpr());
        BigDecimal ZKPrice = originalPrice.multiply(zk);

        if (ZKPrice.compareTo(BigDecimal.ZERO) <= 0) {
            return new BigDecimal(0.01);
        }

        return ZKPrice;
    }
}
